<?php
/**
 * ProjektMan
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 *
 * @category   ProjektMan
 * @name       User.php
 * @license    LICENSE.txt     New BSD License
 */

/**
 * Table model for user
 *
 * @category   ProjektMan
 * @name       User
 * @license    LICENSE.txt     New BSD License
 */
class User extends Projekt_Model
{
	/**
     * get a user id based on username and password
     * used for authentication
     *
     * @param string $username
     * @param string $password
     * @return string
     */
    public static function getUserId($username, $password)
    {
        $db = Projekt_ModelList::getDefaultAdapter();
        $query = "SELECT user_id, username FROM user WHERE username=? AND password=?";
        $row = $db->fetchRow($query, array(
            $username,
            md5($password)
        ));

        return count($row == 1) ? $row['user_id'] : null;
    }
}